package com.ty.controller;

import com.ty.pojo.SettleCase;
import com.ty.service.SettleCaseService;
import com.ty.vo.PageResult;
import com.ty.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@RestController
@CrossOrigin
@EnableSwagger2
@RequestMapping("/settleCase")
public class SettleCaseController {
    @Autowired
    private SettleCaseService settleCaseService;
    //查询断案表
    @GetMapping("/getSettleCaseList")
    public SysResult getSettleCaseList(@RequestBody PageResult pageResult,SettleCase settleCase){
        pageResult = settleCaseService.getSettleCaseList(pageResult,settleCase);
        return SysResult.success(pageResult);
    }
    //新增断案
    @PostMapping("/addSettleCase")
    @Transactional
    public SysResult addSettleCase(@RequestBody SettleCase settleCase){
        settleCaseService.addSettleCase(settleCase);
        return SysResult.success();
    }
    //修改断案
    @PutMapping("/updateSettleCase")
    @Transactional
    public SysResult updateSettleCase(@RequestBody SettleCase settleCase){
        settleCaseService.updateSettleCase(settleCase);
        return SysResult.success();
    }
    //修改断案状态,页面不显示
    @PutMapping("/updateState/{id}")
    @Transactional
    public SysResult updateState(@PathVariable Integer id){
        settleCaseService.updateState(id);
        return SysResult.success();
    }
}
